from django.db import models
from StartGroup.models import Group
from django.contrib.auth.models import User
from django.conf import settings
import datetime

class Member_Group(models.Model):
    group = models.ForeignKey(Group, unique=False)
    user_id = models.CharField(max_length=40, unique=False)
    join_date = models.DateTimeField(auto_now_add = True)
    group_web_address = models.CharField(max_length=10)
    permission = models.IntegerField(max_length=1)
    
    # Userid and group_web_address together make a unique entry
    class Meta:
        unique_together = ("user_id", "group_web_address")


# View Definition for Group Member
class group_mem_assoc_v(models.Model):             
    userid = models.CharField(max_length=40, unique=False)
    group_web_address = models.CharField(max_length=10)
    email = models.CharField(max_length=50)
    is_staff = models.IntegerField(max_length=1)
    photo_path = models.CharField(max_length=100)
    first_name = models.CharField(max_length=25)
    last_name = models.CharField(max_length=25)
    mem_country = models.CharField(max_length=100)
    mem_city = models.CharField(max_length=25)
    join_date = models.DateTimeField(auto_now_add = False)
    group_country = models.CharField(max_length=100)
    group_city = models.CharField(max_length=25)
    group_name = models.CharField(max_length=25)
    permission = models.IntegerField(max_length=1)
    email_setting = models.CharField(max_length=70)
    
    # Since this model refers to a VIEW definition in database,
    # it is not managed by Django
    class Meta:
         managed = False

